package com.guoxin.concurrentcy.chapter2.bank;

/**
 * @author guoxin
 * @date 2019/7/1
 */
public class BankVersion2 {
    private static final int MAX = 50;
    private static int index = 1;
    public static void main(String[] args) {
        Runnable ticketWindowRunnable = () -> {
            while (index <= MAX) {
                try {
                    Thread.sleep(200);
                    System.out.println(Thread.currentThread().getName() + "，当前号码是：" + index++);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        Thread t1 = new Thread(ticketWindowRunnable, "一号窗口");
        Thread t2 = new Thread(ticketWindowRunnable, "二号窗口");
        Thread t3 = new Thread(ticketWindowRunnable, "三号窗口");
        t1.start();
        t2.start();
        t3.start();
    }
}
